package intnet;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class test3 {
	public static void main(String[] args) {

		InetAddress serverIP = null;
		OutputStream os = null;
		Socket socket = null;
		try {
			// 要知道这个地址
			serverIP = InetAddress.getByName("127.0.0.1");
			int port = 9999;
			// 创建一个socket连接
			socket = new Socket(serverIP, port);
			// 发送消息 io流
			os = socket.getOutputStream();
			os.write("你好！".getBytes());

		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			
			if (os != null) {
				try {
					os.close();
				} catch (Exception e2) {
					// TODO: handle exception
				}
			}

			if (socket != null) {
				try {
					socket.close();
				} catch (Exception e2) {
					// TODO: handle exception
				}
			}

		}
	}

}